/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
// pclprntr.hpp
//
// PegPrinter class that supports HP PCL 3 compatible printers.
//
// Author: Jim DeLisle
//
// Copyright (c) 1997-2004 Swell Software, Inc.
//              All Rights Reserved.
//
// Unauthorized redistribution of this source code, in whole or part,
// without the express written permission of Swell Software, Inc.
// is strictly prohibited.
//
// Notes:
//
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

#ifndef PCLPRNTR_HPP_
#define PCLPRNTR_HPP_

#if defined(PEG_PRINTER_SUPPORT)

/*--------------------------------------------------------------------------*/
// All default distances are in HP PCL Units at 300dpi resolution.
/*--------------------------------------------------------------------------*/
typedef struct _PegPCLParms
{
    PEGINT PaperSize;           // from enum in pprinter.hpp
    PEGINT PhysPageWidth;       // physical page width
    PEGINT PhysPageHeight;      // physical page height
    PEGINT LogPageWidth;        // logical page width
    PEGINT LogPageHeight;       // logical page height
    PEGINT HorzPhysLogOffset;   // distance between phys page and log page
    PEGINT VertPhysLogOffset;   // distance between phys page and log page
    PEGINT PhysPrintOffset;     // distance between phys page and printable
    PEGINT PhysGraphOffset;     // distance between phys page and default gl
} PegPCLParms;

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
#define MAX_PCL_CMD_LEN 45

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
class PCLPrinter : public PegPrinter
{
    public:
        PCLPrinter();
        virtual ~PCLPrinter();

        virtual PEGINT BeginDoc(const PegPrintSetup *pSetup = NULL);
        virtual PEGINT BeginPage(void);
        virtual PEGINT Cancel(void);
        virtual PEGINT EndDoc(void);
        virtual PEGINT EndPage(void);

        virtual PEGINT Reset(void);

        virtual PEGINT Setup(const PegPrintSetup *pSetup);

    protected:
        virtual PEGINT SurfaceToPrinter();
        PEGINT CalcDefaultHeight(void);
        PEGINT CalcDefaultWidth(void);
        PegPCLParms *FindParms(PEGINT PaperSize, PEGINT Orient);

        PegPCLParms *mpPCLParms;

    private:
        PEGINT SendPCLCommand(const char *pCmd, const char *pVal = NULL);

        char mCmdStr[MAX_PCL_CMD_LEN];
};

#endif  // PEG_PRINTER_SUPPORT
#endif  // PCLPRNTR_HPP_

